package 商城进货交易记录程序设计;

import java.io.File;
import java.io.IOException;
import java.util.Scanner;

public class DeleteFile implements INoperation{
    @Override
    public void workFIle() throws IOException {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入要删除目录或文件");
        String deletePath = sc.nextLine();
        File file = new File(deletePath);
        if(!file.exists())
        {
            System.out.println("该目录或文件不存在");
            return;
        }
        if(file.isDirectory())
        {
            file.delete();
            System.out.println("该目录已删除");
        }
        else {
            file.delete();
            System.out.println("该文件已删除");
        }
    }
}
